import java.util.Scanner;

public class Test {
        public static void main(String[] args){
            System.out.print("请输入要求的精度值：");
            Scanner sc=new Scanner(System.in);
            double n=sc.nextDouble();
            double pi=0.0;
            double sum=1.0;
            double flag=1.0;
            double i=1.0;
            while(Math.abs(sum)>=n){
                pi=pi+sum;
                flag=-flag;
                i+=2;
                sum=flag/i;
            }
            pi=(pi+sum)*4;
            System.out.println(pi);
        }

    public static void main3(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入数组中元素个数：");
        int n=sc.nextInt();
        int[] Array=new int[n];
        int sum=0;
        double average=0;
        for (int i = 0; i < n; i++) {
            int j=i+1;
            System.out.print("请输入第"+j+"个元素：");
            Array[i]=sc.nextInt();
            sum+=Array[i];
            average+=Array[i];
        }
        average=average/n;
        System.out.println("数组的和为"+sum);
        System.out.println("数组的平均值为"+average);
    }
    public static void main2(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入一个三位数：");
        int n=sc.nextInt();
        int a=n%10;
        int b=n/10%10;
        int c=n/100;
        if(Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3)==n) {
            System.out.println(n + "是水仙花数");
        }
        else {
            System.out.println(n + "不是水仙花数");
        }
    }
    public static void main1(String[] args){
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int sum=0;
        while(a>0){
            sum+=a%10;
            a/=10;
        }
        System.out.println(sum);
    }
}
